<template>
  <div class="box-list-container">
    <div class="box-query-form">
      <el-form :model="queryParam" label-width="auto" label-position="right" :gutter="24">
        <el-row>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="文本框:">
              <el-input v-model="queryParam.text" placeholder="请输入" />
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="下拉单选:">
              <el-select v-model="queryParam.selectData" placeholder="请选择">
                <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :xl="6" :lg="6" :md="12" :sm="24">
            <el-form-item label="下拉多选:">
              <MultipleSelect
                :value="queryParam.mulSelecteds"
                :select-options="options"
                :mul-select-loading="mulSelectLoading"
                select-label-field-name="idCard"
                :update-multiple-select.sync="queryParam.mulSelecteds"
              />
            </el-form-item>
          </el-col>
          <template v-if="toggleSearchStatus">
            <el-col :xl="6" :lg="6" :md="12" :sm="24">
              <el-form-item label="日期:">
                <el-date-picker v-model="queryParam.activateDate" type="date" placeholder="请选择" />
              </el-form-item>
            </el-col>
            <el-col :xl="6" :lg="6" :md="12" :sm="24">
              <el-form-item label="时间:">
                <el-time-select v-model="queryParam.time" placeholder="选择时间" />
              </el-form-item>
            </el-col>
            <el-col :xl="6" :lg="6" :md="12" :sm="24">
              <el-form-item label="日期和时间:">
                <el-date-picker v-model="queryParam.DateTime" type="datetime" placeholder="选择日期时间" />
              </el-form-item>
            </el-col>
          </template>
          <el-col :xl="6" :lg="6" :md="12" :sm="24" class="table-search-btn">
            <el-button icon="el-icon-refresh" @click="searchReset">重置</el-button>
            <el-button type="primary" icon="el-icon-search" @click="searchQuery">查询</el-button>
            <el-link style="margin-left: 10px;" type="primary" :underline="false" @click="handleToggleSearch">
              {{ toggleSearchStatus ? '收起' : '展开' }}
              <i :class="toggleSearchStatus ? 'el-icon-arrow-up' : 'el-icon-arrow-down'" />
            </el-link>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="box-table">
      <div class="table-title">
        <div class="table-title-left">
          通用模板列表
        </div>
        <div>
          <el-button plain class="btnAdd" icon="el-icon-plus" @click="handleAdd('新增')">新增-弹窗</el-button>
          <el-button plain class="btnAdd" icon="el-icon-plus" @click="handleAdd_z(2, '新增')">新增-抽屉</el-button>
          <el-button plain class="btnAdd" icon="el-icon-plus" @click="handleAdd_z(3)">新增-跳转</el-button>
          <el-button type="success" icon="el-icon-download">导出</el-button>
          <el-button type="warning" icon="el-icon-upload2">导入</el-button>
          <importModel export-xls-url="/qk/home/userInfoQKOld/exportXls" import-url="qk/home/userInfoQKOld/importUserExcel" />
        </div>
      </div>
      <!-- 批量操作 -->
      <div v-if="selectedRowList.length" class="batchAction">
        <div class="batchAction-left">
          <el-dropdown>
            <el-button>
              更多菜单 <i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <div @click="batchDelete"><i class="el-icon-delete" />删除</div>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <div class="batchAction-right">
          已选择
          <span style="font-weight: 700">
            <el-link type="primary" :underline="false">{{ selectedRowList.length }}</el-link>
          </span>项
          <el-link type="primary" :underline="false" style="margin-left: 24px;" @click="onClearSelected">清空</el-link>
        </div>
      </div>
      <el-table ref="table" :data="dataSource" @selection-change="onSelectChange">
        <el-table-column type="selection" width="55" />
        <el-table-column fixed="left" label="序号" width="100" type="index" />
        <el-table-column prop="column1" label="列1" width="120" />
        <el-table-column prop="column2" label="列2" />
        <el-table-column prop="column3" label="列3" />
        <el-table-column prop="column4" label="列4" />
        <el-table-column prop="column5" label="列5" />
        <el-table-column fixed="right" label="操作" width="300">
          <template slot-scope="scope">
            <el-button type="text" @click="handleView('查看', scope.row)">查看</el-button>
            <el-button type="text" @click="handleEdit('编辑', scope.row)">编辑</el-button>
            <el-popconfirm title="确定删除吗？" style="margin-left: 10px" @confirm="handleDelete(scope.row.id)">
              <el-button slot="reference" type="text" style="color: red;">删除</el-button>
            </el-popconfirm>
          </template>
        </el-table-column>
        <div slot="empty" class="emptyBg">
          <img src="@/assets/img/emptyData.png">
        </div>
      </el-table>
      <div class="box-paging">
        <pagination
          v-show="ipagination.total > 0"
          layout="total, sizes, prev, pager, next"
          :total="ipagination.total"
          :page.sync="ipagination.pageNum"
          :limit.sync="ipagination.pageSize"
          @pagination="loadData"
        />
      </div>
    </div>
    <!-- 查看 -->
    <viewDrawerModel ref="modalFormView" />
    <!-- 弹窗 -->
    <updateDialogModel ref="modalForm" @ok="modalFormOk" />
    <!-- 抽屉 -->
    <updateDrawerModel ref="updateDrawerModel" @ok="modalFormOk" />
  </div>
</template>

<script>
import { listMixin } from '@/mixins/listMixin'
import Pagination from '@/components/Pagination'
import MultipleSelect from '@/components/xm/MultipleSelect'
import viewDrawerModel from './components/viewDrawerModel'
import updateDialogModel from './components/updateDialogModel'
import updateDrawerModel from './components/updateDrawerModel'
import importModel from './components/importModel'
export default {
  name: 'BaseTemplate',
  components: {
    Pagination,
    MultipleSelect,
    viewDrawerModel,
    updateDialogModel,
    importModel,
    updateDrawerModel
  },
  mixins: [listMixin],
  data() {
    return {
      toggleSearchStatus: false, // 展开收起
      mulSelectLoading: false, // 下拉多选isLoading
      options: [
        {
          label: '选项1',
          idCard: '421221199311110055',
          value: 1
        }, {
          label: '选项2',
          idCard: '421221199311110055',
          value: 2
        }, {
          label: '选项3',
          idCard: '421221199311110055',
          value: 3
        }, {
          label: '选项4',
          value: 4
        }, {
          label: '选项5',
          value: 5
        }, {
          label: '选项6',
          value: 7
        }
      ],
      url: {
        list: 'http://47.92.154.219:200/api/TemplateTable.aspx?action=GetList',
        delete: 'http://47.92.154.219:200/api/TemplateTable.aspx?action=Delete',
        deleteBatch: 'http://47.92.154.219:200/api/TemplateTable.aspx?action=deleteBatch'
      }
    }
  },
  created() {},
  mounted() {},
  methods: {
    // 新增
    handleAdd_z(showType, title) {
      console.log('新增')
      if (showType === 2) { // 打开抽屉
        this.$refs.updateDrawerModel.add()
        this.$refs.updateDrawerModel.title = title
        this.$refs.updateDrawerModel.isClick = false
      } else if (showType === 3) { // 跳转
        // 跳转新增或编辑
        this.$router.push({
          name: 'updatePageModel',
          params: { title: '新增', updatePageState: 'add' }
        })
      }
    },
    // 展开收起
    handleToggleSearch() {
      this.toggleSearchStatus = !this.toggleSearchStatus
    }
  }
}
</script>

<style lang="scss" scoped>
</style>

